<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      // 小学生类
      var Pupil = function (name, age, sex, hobby, birthday) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.hobby = hobby;
        this.birthday = birthday;
      };
      Pupil.prototype.introduce = function () {
        console.log( "您好, 我叫" + this.name + ", 是一个" + this.sex + "生, 今年" + this.age + "岁了, 喜欢看" + this.hobby + ", " + this.birthday + "是我的生日" );
      };
      //小学生原型继承学生类原型；
      Pupil.prototype = new Student();
      // 大学生类
      var Undergraduate = function ( name, age, sex, hobby, major, school, LoverName ) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.hobby = hobby;
        this.major = major;
        this.school = school;
        this.LoverName = LoverName;
      };
      Undergraduate.prototype.introduce = function () {
        console.log( "你好, 我叫" + this.name + ", 今年" + this.age + "性别" + this.sex + "，就读于" + this.school + ", " + this.major + "专业，爱好" + this.hobby + ",我的" + (this.sex == "男" ? "女" : "男") + "朋友叫" + this.LoverName );
      };
      //大学生原型继承学生原型；
      Undergraduate.prototype = new Student();
      // 学生类
      var Student = function (name, age, sex, hobby) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.hobby = hobby;
      };
      Student.prototype.introduce = function () {};
      //学生原型继承人类类原型；
      Student.prototype = new People();
      // 老师类
      var Teacher = function (name, age, sex, rank, salary) {
        this.name = name;
        this.age = age;
        this.sex = sex;
        this.rank = rank;
        this.salary = salary;
      };
      Teacher.prototype.introduce = function () {
        console.log( "我是" + this.name + "老师，性别" + this.sex + ", " + this.age + "岁, 现担任" + this.rank + "一职，工资到手 " + this.salary + "，我很幸福" );
      };
      //老师原型继承人类类原型；
      Teacher.prototype = new People();

      // 人类
      var People = function (name, age, sex) {
        this.name = name;
        this.age = age;
        this.sex = sex;
      };
      People.prototype.introduce = function () {};

      //   小明的自我介绍
      var xiaoming = new Pupil("小明", "5", "男", "《奥特曼》", "2016年4月1日");
      xiaoming.introduce();
      //   小红的自我介绍
      var xiaohong = new Pupil( "小红", "4", "女", "《喜洋洋与灰太狼》", "2017年6月2日" );
      xiaohong.introduce();
      //   李雷的自我介绍
      var lilei = new Undergraduate( "李雷", "18", "男", "看电影", "日语", "哈尔滨工业大学", "韩梅梅" );
      lilei.introduce();
      //   韩梅梅的自我介绍
      var hanmeimei = new Undergraduate( "韩梅梅", "21", "女", "钓鱼", "土木工程", "海南大学", "李雷" );
      hanmeimei.introduce();
      //   张三强的自我介绍
      var zhangsanqiang = new Teacher("张三强", "53", "男", "系主任", "1800");
      zhangsanqiang.introduce();
    </script>
  </body>
</html>
